package com.cos.lession70.common;

import org.springframework.beans.factory.FactoryBean;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @author: COS
 * @time: 2022/9/26 15:31
 * @description:
 */
public class MyConnection implements FactoryBean<Connection> {

    @Override
    public Connection getObject() throws Exception {
        // 实现复杂对象的创建
        Class.forName("com.mysql.jdbc.Driver");
        Connection cos = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/qf2204?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8",
                "cos",
                "123456");
        return cos;
    }
    /**
     *
     * @author: COS
     * @return:
     * @time: 2022/9/26 15:32
     * @description: 返回这个bean的数据类型
     */
    @Override
    public Class<?> getObjectType() {
        return Connection.class;
    }
    /**
     *
     * @author: COS
     * @return:
     * @time: 2022/9/26 15:32
     * @description: 是否为单例模式
     */
    @Override
    public boolean isSingleton() {
        return false;
    }
}
